package com.utils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class ThreadLocalDateUtil {
    private static final String date_format = "yyyy年MM月dd日 E ";
    private static ThreadLocal<DateFormat> threadLocal = new ThreadLocal<DateFormat>();
    private static String alltime;
    private static String ttime;
    private static String tdime;
    public static DateFormat getDateFormat()
    {
        DateFormat df = threadLocal.get();
        if(df==null){
            df = new SimpleDateFormat(date_format);
            threadLocal.set(df);
        }
        return df;
    }

    public static String formatDate(Date date) throws ParseException {

        return getDateFormat().format(date);
    }
//    public  String getAlltime() throws ParseException {
//
//        return getDateFormat().format(date);
//    }

//    public static String gettime() throws ParseException {
//
//        return getDateFormat().format(date);
//    }
//    public static String getdtime() throws ParseException {
//
//        return getDateFormat().format(date);
//    }
    public static Date parse(String strDate) throws ParseException {
        return getDateFormat().parse(strDate);
    }
}